package com.weixing.mall.provider.model.excel;

import cn.hutool.core.util.StrUtil;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ContentRowHeight;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.weixing.mall.base.constant.DatePattern;
import com.weixing.mall.base.constant.GlobalConstant;
import com.weixing.mall.core.enums.OrderSysTagEnum;
import com.weixing.mall.provider.model.enums.NoSuppllyAuditEnum;
import lombok.Data;

import java.math.BigDecimal;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Date;

/**
 *
 * @Author 0202
 * @Date 2020-8-21
 * @Version 1.0
 */
@Data
@ContentRowHeight(100)
public class KefuAuditOrderED {

    @ExcelProperty("订单编号")
    private String orderSn;
    @ExcelProperty("年份和月份")
    private String calcelTime;
    @ExcelProperty("支付流水号")
    private String outTradeNo;
    @ExcelProperty("商品名称")
    private String goodsName;
    @ExcelProperty("图片")
    @ExcelIgnore
    private String productImg;
    @ExcelProperty("图片")
    private URL img;
    @ExcelProperty("货号")
    private String goodsSn;
    @ExcelProperty("款号")
    private String styleNo;
    @ExcelProperty("颜色/尺码")
    @ExcelIgnore
    private String productSkuDesp;
    @ExcelProperty("颜色")
    private String color;
    @ExcelProperty("尺码")
    private String size;
    @ExcelProperty("订单价格")
    private BigDecimal orderPrice;
    @ExcelProperty("收货人")
    private String contactUser;
    @ExcelProperty("收货人手机号")
    private String contactPhone;
    @ExcelProperty("下单人")
    private String buyer;
    @ExcelProperty("下单时间")
    @JsonFormat(locale = "zh", timezone = "GMT+8", pattern = DatePattern.NORM_DATETIME_PATTERN)
    private Date createdTime;
    @ExcelProperty("所属代理商")
    private String agentName;
    @ExcelProperty("所属客服")
    private String customerName;
    @ExcelProperty("审核时间")
    @JsonFormat(locale = "zh", timezone = "GMT+8", pattern = DatePattern.NORM_DATETIME_PATTERN)
    private Date auditTime;
    @ExcelProperty("所属发货员")
    private String shipperName;
    @ExcelProperty("系统标签")
    private String sysTagStr;
    @ExcelProperty("系统标签")
    @ExcelIgnore
    private OrderSysTagEnum sysTag;
    @ExcelProperty("取消审核状态")
    private String nosuppllyAuditStr;
    @ExcelProperty("取消审核状态")
    @ExcelIgnore
    private NoSuppllyAuditEnum nosuppllyAudit;

    @ExcelProperty("活动名称")
    private String actName;

    @ExcelProperty("快递方式")
    private String expressName;

    @ExcelProperty("是否换货")
    @ExcelIgnore
    private Integer afterSaleTag;
    @ExcelProperty("是否换货")
    private String afterSaleTagStr;

    public void setProductImg(String productImg){
        this.productImg = productImg;
        try {
            if (StrUtil.isNotEmpty(productImg)){
                this.img=new URL(GlobalConstant.IMG_PATH_URL +productImg+GlobalConstant.IMG_PATH_URL_SUFFIX);
            }
        } catch (MalformedURLException e) {
            e.printStackTrace();
        }
    }

    public void setSysTag(OrderSysTagEnum sysTag){
        this.sysTag = sysTag;
        if(sysTag != null){
            this.sysTagStr = sysTag.getDesp();
        }
    }
    public void setNosuppllyAudit(NoSuppllyAuditEnum nosuppllyAudit){
        this.nosuppllyAudit = nosuppllyAudit;
        if(nosuppllyAudit != null){
            this.nosuppllyAuditStr = nosuppllyAudit.getDesp();
        }else{
            this.nosuppllyAuditStr = "未审核";
        }
    }

    public void setAfterSaleTag(Integer afterSaleTag){
        this.afterSaleTag = afterSaleTag;
        if (afterSaleTag != null && afterSaleTag == 1 ) {
           this.afterSaleTagStr = "是";
        }else{
           this.afterSaleTagStr = "否";
        }
    }

}
